package com.volunteer.controller.admin;

import com.volunteer.common.Result;
import com.volunteer.service.BlackUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 黑名单用户管理控制器
 */
@Tag(name = "管理端-黑名单用户管理")
@RestController
@RequestMapping("/api/admin/blackuser")
@RequiredArgsConstructor
public class AdminBlackUserController {

    private final BlackUserService blackUserService;

    /**
     * 添加用户到黑名单
     */
    @Operation(summary = "添加用户到黑名单")
    @PostMapping("/add")
    public Result addToBlacklist(@Parameter(description = "用户ID") @RequestParam Long userId) {
        return blackUserService.addToBlacklist(userId);
    }

    /**
     * 从黑名单中移除用户
     */
    @Operation(summary = "从黑名单中移除用户")
    @PostMapping("/remove")
    public Result removeFromBlacklist(@Parameter(description = "用户ID") @RequestParam Long userId) {
        return blackUserService.removeFromBlacklist(userId);
    }

    /**
     * 分页查询黑名单用户
     */
    @Operation(summary = "分页查询黑名单用户")
    @GetMapping("/page")
    public Result getBlacklistPage(
            @Parameter(description = "当前页码") @RequestParam(defaultValue = "1") Integer current,
            @Parameter(description = "每页数量") @RequestParam(defaultValue = "10") Integer size) {
        return blackUserService.getBlacklistPage(current, size);
    }

    /**
     * 检查用户是否在黑名单中
     */
    @Operation(summary = "检查用户是否在黑名单中")
    @GetMapping("/check")
    public Result checkUserInBlacklist(@Parameter(description = "用户ID") @RequestParam Long userId) {
        boolean inBlacklist = blackUserService.isUserInBlacklist(userId);
        return Result.success(inBlacklist);
    }
} 